﻿CREATE PROCEDURE [dbo].[Partner_HotCd_Update]
	@items [dbo].[partner_HotcdItem] READONLY
AS
BEGIN
	BEGIN TRY
		BEGIN TRAN

			TRUNCATE TABLE [dbo].[partner_Hotcd]

			INSERT INTO [dbo].[partner_Hotcd]
				([ItemId], [Title] ,[Price], [Description], [New], [Type])
			SELECT [Id], [Title], [Price], [Description], [New], [Type]
			FROM @items

		COMMIT TRAN
	END TRY
	BEGIN CATCH
		ROLLBACK TRAN

		DECLARE @ErrorMessage NVARCHAR(4000);
		DECLARE @ErrorSeverity INT;
		DECLARE @ErrorState INT;

		SELECT	@ErrorMessage = ERROR_MESSAGE(),
						@ErrorSeverity = ERROR_SEVERITY(),
						@ErrorState = ERROR_STATE();

		RAISERROR (
								@ErrorMessage, -- Message text.
								@ErrorSeverity, -- Severity.
								@ErrorState -- State.
							);
	END CATCH
END